package top.carrotguo.dynamic;

/**
 * @Author: Carrot
 * @Mail: 1053155183carrot@gmail.com
 * @Date: Created in 9:10 2018-05-14
 */
public class Fib {

    public static int fib(int n){
        int f = 0, g = 1;
        while (0<n--) {
            g = f+g;
            f = g-f;
        }
        return g;
    }

    public static void main(String[] args){
        System.out.print("fib6="+fib(5));
    }
}
